package com.hdu.point_offer;

public class lcr177 {
    class Solution {
        public int[] sockCollocation(int[] sockets) {
            int bitDiff = 0;
            for (int i = 0; i < sockets.length; i++)
            {
                bitDiff ^= sockets[i];
            }
            int m = 1;
            while ((bitDiff & m) == 0)
            {
                m <<= 1;
            }
            int x = 0;
            int y = 0;
            for (int i = 0; i < sockets.length; i++)
            {
                if ((sockets[i] & m) == 0)
                {
                    x ^= sockets[i];
                }
                else
                {
                    y ^= sockets[i];
                }
            }
            return new int[]{x, y};
        }
    }
}
